package com.haisen.common.utils;

public class ThreadWithCatch extends Thread {

    private final MyFun fn;

    public ThreadWithCatch(MyFun fn) {
        this.fn = fn;
    }

    @Override
    public void run() {
        try {
            fn.run();
        } catch (Throwable e) {
            throw new RuntimeException(e);
        }
    }

    public static void main(String[] args) {
        new ThreadWithCatch(() -> {
            System.out.println(111111);
            Thread.sleep(1000);             // 生气 try-catch
            System.out.println(222222);
        }).start();
    }
}
